package org.aplikator.server.rpc.handler;

import org.aplikator.client.data.PrimaryKey;
import org.aplikator.client.descriptor.ViewDTO;
import org.aplikator.client.rpc.impl.GetRecord;
import org.aplikator.client.rpc.impl.GetRecordResponse;
import org.aplikator.server.Context;
import org.aplikator.server.persistence.Persister;
import org.aplikator.server.persistence.PersisterFactory;
import org.aplikator.server.rpc.CommandHandler;

public class GetRecordHandler implements CommandHandler<GetRecord, GetRecordResponse> {

    private Persister persister = PersisterFactory.getPersister();

    public GetRecordHandler() {

    }

    public GetRecordResponse execute(GetRecord command, Context context) {
        ViewDTO view = command.getView();
        PrimaryKey pk = command.getPrimaryKey();
        return new GetRecordResponse(persister.getRecord(view, pk, context));
    }

}
